package com.rui.study.micro.shoppingbag.client;

import com.netflix.discovery.shared.Application;
import feign.Body;
import feign.Headers;
import feign.Param;
import feign.RequestLine;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;

@FeignClient(name = "com.rui.study.micro.common.eureka", fallback = DiscoveryClient.DiscoveryClientImpl.class)
public interface DiscoveryClient {



    @RequestLine("POST /api/svr")
    @Headers({"Content-Type: text/plain;charset=utf-8"})
    @Body("{appName}")
    Application fetchApplication(@Param("appName") String appName);


    @Slf4j
    @Component
    class DiscoveryClientImpl implements DiscoveryClient {

        @Override
        public Application fetchApplication(String appName) {
            log.warn("服务降级...");
            return null;
        }
    }
}
